C Programming 2075
Attempt any two questions:
AI is thinking...
1. What is looping statement? Discuss different looping statements with suitable example of each. (2+8)
AI is thinking...
2. Define array? What are the benefits of using array? Write a program to add two matrices using array. (1+2+7)
AI is thinking...
3. Why do we need data files? What are the different file opening modes? Write a program that reads data from a file "input.txt" and writes to "output.txt" file.
AI is thinking...
Attempt any eight questions:
AI is thinking...
4. Discuss different logical operators in detail.
AI is thinking...
5. What is break statement? Discuss with example. How the break statement is different from continue statement?
AI is thinking...
6. Write a program to check whether a number entered is even or odd.
#include <stdio.h>
int main() {
int num;
printf("Enter an integer: ");
scanf("%d", &num);
if(num % 2 == 0)
printf("%d is even.", num);
else
printf("%d is odd.", num);
return 0;
}
AI is thinking...
7. Write a program to calculate sum of first 10 odd numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int s = 0, i;
for (i = 1; i<10; i++)
{
if(i%2!=0)
{
s = s + i;
}
}
printf("%d",s);
getch();
}
AI is thinking...
8. What is preprocessor directive? Discuss # define directive with example.
AI is thinking...
9. Discuss any five string library functions.
Five string library functions are given below:
1. strlen(): It returns the number of characters in a string.
syntax: strlen(string_name)
2. strcpy(): It copies the contents of source string to destination string.
syntax: strcpy(destination_string, source_string)
3. strcat(): It concats or joins first string with second string. The result of the string is stored in first string.
syntax: strcat(first_string, second_string)
4. strcmp(): It compares the first string with second string. If both strings are same, it returns 0.
syntax: strcmp(first_string, second_string)
5. strstr(): It is used to search whether a substring is present in the main string or not.
syntax: strstr(mainsring, substring)
AI is thinking...
10. What is dynamic memory allocation? Discuss the use of malloc() in dynamic memory allocation with example.
AI is thinking...
11. What is structure? Create a structure rectangle with data members length and breadth.
AI is thinking...
12. Write short notes on:
(a) Benefits of data files
(b) Graphics functions.
AI is thinking...