Unit - I: For (Initialization Condition Increment/decrement) (//code)
Unit - I: For (Initialization Condition Increment/decrement) (//code)
For Loop: Executes a sequence of statements multiple times and abbreviates the
code that manages the loop variable. Syntax: for(initialization; condition;
increment/decrement) { //code }
QA102: Write a program to initialize the value as 7680 & display the value on the
monitor.
c Copy code
c Copy code
Output Explanation:
The program will print 0 and then terminate because the return 0; statement is inside the
infinite loop, but it executes immediately after the first iteration.
QA105: Write a C program to find area and circumference of circle.
c Copy code
UNIT - II
QA201: Discuss the types of arguments passing in C.
QA202: Compare the pointer and pointer to pointer variable with suitable example.
Example:
c Copy code
#include <stdio.h> int main() { int var = 10; int *p = &var; int **pp = &p;
printf("Value of var: %d\n", var); printf("Address of var: %p\n",
(void*)&var); printf("Value of p (Address of var): %p\n", (void*)p);
printf("Value at *p (Value of var): %d\n", *p); printf("Value of pp (Address
of p): %p\n", (void*)pp); printf("Value at *pp (Value of p): %p\n",
(void*)*pp); printf("Value at **pp (Value of var): %d\n", **pp); return 0; }
QA203: Write a C program to print the address of variable, pointer and pointer value.
(Assume “i” is variable and “p” is pointer )
c Copy code
QA204: Write a C program to find greatest among three numbers using functions
(Without argument and with return type)
c Copy code
c Copy code
#include <stdio.h> int main() { int a, b, result; int *p1, *p2; printf("Enter
two integers: "); scanf("%d %d", &a, &b); p1 = &a; p2 = &b; result = (*p1) *
(*p2); printf("Multiplication result: %d\n", result); return 0; }
UNIT - III
QA301: Illustrate the Array and how to initialize an array?
Example:
c Copy code
int arr[2][3][4] = { { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12} }, { {13,
14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24} } };
Diagram:
c Copy code
Output Explanation:
The program searches for the element 30 in the array and prints its position, which is 2 (1-
based index).
QA304: Create a C program to read n elements as input and print the sum of all
elements of the array (integer).
c Copy code
Structure: A user-defined data type that groups related variables of different data
types.
Example:
c Copy code
#include <stdio.h> struct Student { char name[50]; int age; float marks; };
int main() { struct Student s1 = {"John", 20, 85.5}; printf("Name: %s\n",
s1.name); printf("Age: %d\n", s1.age); printf("Marks: %.2f\n", s1.marks);
return 0; }
c Copy code
Output Explanation:
The program initializes a structure with a string and an integer and prints: nagu 1981.
Example:
c Copy code
#include <stdio.h> struct Node { int data; struct Node *next; }; int main() {
struct Node node1; node1.data = 10; node1.next = NULL; printf("Data: %d\n",
node1.data); return 0; }
#include<stdio.h> int main() { union test { int i; int j; }; union test var =
{10}; printf("%d,%d\n", var.i, var.j); return 0; }
Output Explanation:
The program initializes the union with a value of 10 and prints: 10,10.
c Copy code
UNIT - V
QA501: Write a program to find sum of two fraction values
c Copy code
c Copy code
Example:
c Copy code
#include <stdio.h> int main() { int a = 10, b = 20; int max = (a > b) ? a : b;
printf("Max value is: %d\n", max); return 0; }
QA504: Write a C program to concatenate two strings without using strcat() using while
loop.
c Copy code
c Copy code
This should cover the provided questions for the units. Let me know if you need further
assistance!