Author: BIM Notes
1st Sem Pre Board 2024
NCCS orchid SDC
Continue ReadingC Programming 2022 Solution New Syllabus
11.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <stdio.h> // Function to find the greatest of three numbers int findGreatest(int num1, int num2, int num3) { if (num1 > num2 && num1 > num3) { return num1; } else if (num2 > num3) { return num2; } else { return num3; } } int main() { int num1, num2, num3; printf("Enter three numbers: "); scanf("%d %d %d", &num1, &num2, &num3); int greatest = findGreatest(num1, num2, num3); printf("The greatest number is: %d\n", greatest); return 0; } |
12.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include <stdio.h> #include <string.h> int main() { char str[100]; // Assuming the maximum length of the string is 100 characters printf("Enter a string: "); scanf("%[^\n]", str); // Read the string with spaces until newline int length = strlen(str); printf("Length of the string: %d\n", length); return 0; } |
13. The main difference between a while loop and a do-while loop lies in when the loop condition is checked: While Loop: In a while loop, the condition is checked before the loop body is executed. If the condition is false initially, the loop body will not execute at all. […]
Continue ReadingC programming 2023 New Syllabus Solution
Group A Group B 11. 12. Data types in C programming include int, float, double, char, and more. They are used to define the type of data that a variable can store and determine the operations that can be performed on that data. In C programming, there are several data types, including: int: […]
Continue Reading