Q1.
Pattern Printing
--------------------
Code:
#include <stdio.h>
int main() {
char ch;
for (int i = 7; i >= 1; i--) {
ch = 'A';
for (int j = 1; j <= i; j++) {
printf("%c ", ch);
ch++;
printf("\n");
return 0;
Output:
ABCDEFG
ABCDEF
ABCDE
ABCD
ABC
AB
A
Q2. Multiplication Table
------------------------
Code:
#include <stdio.h>
int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
for (int i = 1; i <= 10; i++) {
printf("%d * %d = %d\n", num, i, num * i);
return 0;
Output:
Enter a number: 10
10 * 1 = 10
10 * 2 = 20
...
10 * 10 = 100
Q3. i Power j
-------------
Code:
#include <stdio.h>
#include <math.h>
int main() {
int i, j, result;
printf("Enter value of i = ");
scanf("%d", &i);
printf("Enter value of j = ");
scanf("%d", &j);
result = pow(i, j);
printf("The result is = %d\n", result);
return 0;
Output:
Enter value of i = 2
Enter value of j = 4
The result is = 16
Q4. Greatest of 3 Numbers
-------------------------
Code:
#include <stdio.h>
int main() {
int a, b, c, max;
printf("Enter 1st value = ");
scanf("%d", &a);
printf("Enter 2nd value = ");
scanf("%d", &b);
printf("Enter 3rd value = ");
scanf("%d", &c);
max = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
printf("The greatest value is = %d\n", max);
return 0;
Output:
Enter 1st value = 2
Enter 2nd value = 5
Enter 3rd value = 1
The greatest value is = 5
Q5. Reverse an Array
--------------------
Code:
#include <stdio.h>
int main() {
int arr[5];
printf("Enter 5 values: ");
for (int i = 0; i < 5; i++) {
scanf("%d", &arr[i]);
printf("The reverse values in array = ");
for (int i = 4; i >= 0; i--) {
printf("%d ", arr[i]);
return 0;
Output:
Enter 5 values: 1 2 1 3 5
The reverse values in array = 5 3 1 2 1
Q6. Larger of Two Numbers using Function
----------------------------------------
Code:
#include <stdio.h>
int larger(int a, int b) {
return (a > b) ? a : b;
int main() {
int num1, num2;
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
int max = larger(num1, num2);
printf("The larger number is: %d\n", max);
return 0;
Output:
Enter first number: 75
Enter second number: 23
The larger number is: 75