c practical with output 1
c practical with output 1
#include <stdio.h>
#include <conio.h>
void main() {
int a, b;
clrscr();
if (a > b) {
} else {
getch();
Output Example:
8 is greater
#include <stdio.h>
#include <conio.h>
void main() {
int num;
clrscr();
scanf("%d", &num);
if (num < 0) {
printf("Number is negative");
} else {
getch();
Output Example:
Enter a number: -7
Number is negative
#include <stdio.h>
#include <conio.h>
void main() {
int num;
clrscr();
scanf("%d", &num);
if (num % 2 == 0) {
printf("Even number");
} else {
printf("Odd number");
getch();
Output Example:
Enter a number: 11
Odd number
#include <conio.h>
void main() {
clrscr();
} else {
getch();
Output Example:
#include <stdio.h>
#include <conio.h>
void main() {
float p, r, t, si;
clrscr();
si = (p * r * t) / 100;
Output Example:
#include <stdio.h>
#include <conio.h>
void main() {
int year;
clrscr();
scanf("%d", &year);
printf("Leap Year");
} else {
getch();
Output Example:
Leap Year
#include <stdio.h>
#include <conio.h>
void main() {
int i;
clrscr();
getch();
Output:
1 2 3 4 5 6 7 8 9 10
#include <stdio.h>
#include <conio.h>
void main() {
int i, sum = 0;
clrscr();
sum += i;
getch();
Output:
Sum = 55
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
printf("Enter a number: ");
scanf("%d", &num);
if (num <= 1) {
} else {
if (num % i == 0) {
flag = 1;
break;
if (flag == 0) {
printf("Prime number");
} else {
getch();
Output Example:
Enter a number: 7
Prime number
#include <stdio.h>
#include <conio.h>
void main() {
int day;
clrscr();
if (day == 1) {
printf("Sunday");
} else if (day == 2) {
printf("Monday");
} else if (day == 3) {
printf("Tuesday");
} else if (day == 4) {
printf("Wednesday");
} else if (day == 5) {
printf("Thursday");
} else if (day == 6) {
printf("Friday");
} else if (day == 7) {
printf("Saturday");
} else {
printf("Invalid Input");
getch();
Output Example:
Thursday
#include <stdio.h>
#include <conio.h>
void main() {
int month;
clrscr();
if (month == 1) {
printf("January");
} else if (month == 2) {
printf("February");
} else if (month == 3) {
printf("March");
} else if (month == 4) {
printf("April");
} else if (month == 5) {
printf("May");
} else if (month == 6) {
printf("June");
} else if (month == 7) {
printf("July");
} else if (month == 8) {
printf("August");
} else if (month == 9) {
printf("September");
printf("October");
printf("November");
printf("December");
} else {
printf("Invalid Input");
getch();
Output Example:
#include <stdio.h>
#include <conio.h>
void main() {
int i;
clrscr();
getch();
Output:
1 2 3 4 5 6 7 8 9 10
#include <stdio.h>
#include <conio.h>
void main() {
int i, sum = 0;
clrscr();
sum += i;
getch();
Output:
Sum = 55
14. Print n Natural Numbers and Their Sum
#include <stdio.h>
#include <conio.h>
void main() {
int i, n, sum = 0;
clrscr();
printf("Enter n: ");
scanf("%d", &n);
sum += i;
getch();
Output Example:
Enter n: 5
12345
Sum = 15
#include <stdio.h>
#include <conio.h>
void main() {
float avg;
clrscr();
scanf("%d", &num);
sum += num;
getch();
Output Example:
Enter 10 numbers: 5 10 15 20 25 30 35 40 45 50
#include <stdio.h>
#include <conio.h>
void main() {
int i, n;
clrscr();
printf("Enter n: ");
scanf("%d", &n);
getch();
Output Example:
Enter n: 5
Cube of 1 = 1
Cube of 2 = 8
Cube of 3 = 27
Cube of 4 = 64
Cube of 5 = 125
#include <stdio.h>
#include <conio.h>
void main() {
int num, i;
clrscr();
scanf("%d", &num);
getch();
Output Example:
Enter a number: 5
5x1=5
5 x 2 = 10
...
5 x 10 = 50
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
if (num <= 1) {
} else {
if (num % i == 0) {
flag = 1;
break;
if (flag == 0) {
printf("Prime number");
} else {
getch();
Output Example:
Enter a number: 7
Prime number
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &num);
temp = num;
while (temp != 0) {
temp /= 10;
if (sum == num) {
printf("Armstrong number");
} else {
getch();
Output Example:
Armstrong number
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
void main() {
char str[100];
clrscr();
gets(str);
if (isupper(str[i])) {
upper++;
} else if (islower(str[i])) {
lower++;
printf("Uppercase string");
printf("Lowercase string");
} else {
getch();
Output Example:
Uppercase string
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%f", &radius);
Output Example:
Enter radius: 5
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &a[i][j]);
scanf("%d", &b[i][j]);
printf("Sum of matrices:\n");
}
printf("\n");
getch();
Output Example:
123
456
789
987
654
321
Sum of matrices:
10 10 10
10 10 10
10 10 10
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%f", &celsius);
getch();
}
Output Example:
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &num);
fact *= i;
getch();
Output Example:
Enter a number: 5
Factorial = 120
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &num);
temp = num;
temp /= 10;
if (num == rev) {
printf("Palindrome number");
} else {
printf("Not a Palindrome");
getch();
Output Example:
Palindrome number
#include <stdio.h>
#include <conio.h>
void main() {
int i, j;
clrscr();
printf("\n");
getch();
}
Output:
12
123
1234
12345
#include <stdio.h>
#include <conio.h>
void main() {
int i, j;
clrscr();
printf("\n");
getch();
Output:
22
333
4444
55555
#include <stdio.h>
#include <conio.h>
void main() {
int i, j;
clrscr();
printf("* ");
printf("\n");
getch();
Output:
**
***
****
*****
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &num);
num /= 10;
count++;
}
printf("Number of digits = %d", count);
getch();
Output Example:
Number of digits = 4
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &arr[i]);
sum += arr[i];
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
Sum = 55
#include <stdio.h>
#include <conio.h>
void main() {
int arr[10], i;
clrscr();
scanf("%d", &arr[i]);
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
Reversed Array: 10 9 8 7 6 5 4 3 2 1
#include <stdio.h>
#include <conio.h>
void main() {
int arr[10], i;
clrscr();
scanf("%d", &arr[i]);
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
Even numbers: 2 4 6 8 10
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &arr[i]);
if (arr[i] % 2 == 0) {
sum += arr[i];
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &arr1[i]);
arr2[i] = arr1[i];
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
Copied array: 1 2 3 4 5 6 7 8 9 10
#include <stdio.h>
#include <conio.h>
void main() {
clrscr();
scanf("%d", &arr1[i]);
arr2[j] = arr1[i];
getch();
Output Example:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10