0% found this document useful (0 votes)
44 views

1 C Program List

The document outlines topics and programs for learning C programming. It covers variable declaration, operators, decision making, loops, arrays, functions, pointers, structures, unions and strings. For each topic, 6-8 programs are listed as examples to write including printing patterns, calculating roots of quadratic equations, finding prime numbers, concatenating strings, and more. The goal is to provide a comprehensive set of examples to learn core C programming concepts.

Uploaded by

pancham8256
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

1 C Program List

The document outlines topics and programs for learning C programming. It covers variable declaration, operators, decision making, loops, arrays, functions, pointers, structures, unions and strings. For each topic, 6-8 programs are listed as examples to write including printing patterns, calculating roots of quadratic equations, finding prime numbers, concatenating strings, and more. The goal is to provide a comprehensive set of examples to learn core C programming concepts.

Uploaded by

pancham8256
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

Topic 1: Variable declaration, data types, Formatted input and output functions, operators

and expressions.

Program 1: WAP to print “hello world” on screen.


program 2: WAP to show various ways in which “printf” can be used to display various messages.
Program 3: WAP to perform various arithmetic operations.
Program 4: WAP to calculate simple interest.
Program 5: WAP to calculate average of two numbers.
Program 6: WAP to convert centigrade temperature to fahrenheit and vice versa.

Topic 2: Operators(modulus operator, logical operators, conditional(ternary) operator) and


expressions

Program 1: WAP to calculate area and circumference of circle.


Program 2: WAP to show swapping of two numbers.
Program 3: WAP to show use of relational operators and logical.
Program 4: WAP to find the greatest of 2 numbers using conditional(ternary) operator.
Program 5: WAP to find whether number is positive or negative using conditional(ternary) operator.
Program 6: WAP to ask the value of y from user and show following conditions using
conditional(ternary) operator.
y+1 if y>0
x= 10 ify=0
y*4 if y<0
Program 7: WAP to show the use of sizeof operator.
Program 8: WAP to show typecasting.

Imp exam:

#include <stdio.h>
int main()
{
int a = 1;
printf("%d %d %d %d %d\n", a++, a++, a++,a++,a++);
a = 1;
printf("%d %d %d %d %d\n", a++, a++, a++,++a,a++);
a = 1;
printf("%d %d %d %d %d\n", a++, a++, ++a,++a,a++);
a = 1;
printf("%d %d %d %d %d\n", a++, ++a, ++a,++a,a++);
return 0;
}

Topic 3: Decision making(if, if-else, nested if-else), Control transfer(goto, break, continue) and
switch statements

Program 1: WAP to show greatest of 2 or 3 numbers using if-else.


Program 2: WAP to find that year entered is leap year or not using if-else.
Program 3: WAP to find the number is even or odd using if-else.
Program 4: WAP to show following conditions using nested if else statement:
gender: male salary>10000 then bonus should be 1000
salary <10000 and >5000, then bonus=500
salary <5000, then bonus=100
gender:female salary>10000 then bonus should be 100
salary <10000 and >5000, then bonus=50
salary <5000, then bonus=10
Program 5: WAP to calculate roots of a quadratic equation.

#include <stdio.h>
#include <math.h>

int main() {
double a, b, c, discriminant, root1, root2, realPart, imaginaryPart;

// get the coefficients of the quadratic equation from the user


printf("Enter coefficients a, b and c: ");
scanf("%lf %lf %lf", &a, &b, &c);

// calculate the discriminant


discriminant = b*b - 4*a*c;

// check the value of the discriminant to determine the type of roots


if (discriminant > 0) {
// real and different roots
root1 = (-b + sqrt(discriminant)) / (2*a);
root2 = (-b - sqrt(discriminant)) / (2*a);
printf("Roots are: %.2lf and %.2lf", root1, root2);
}
else if (discriminant == 0) {
// real and equal roots
root1 = root2 = -b / (2*a);
printf("Roots are: %.2lf and %.2lf", root1, root2);
}
else {
// complex roots
realPart = -b / (2*a);
imaginaryPart = sqrt(-discriminant) / (2*a);
printf("Roots are: %.2lf+%.2lfi and %.2lf-%.2lfi", realPart, imaginaryPart, realPart,
imaginaryPart);
}

return 0;
}
----------------------------------------------------------------------------------------------------------------

Program 6: WAP using switch statement, asking the user to enter a day(sunday, monday, tuesday,
etc). If the user has entered saturday or sunday then display a message saying “enjoy! Its holiday”,
else display a message saying “so sad, u still have to work”, showing use of break statement also.

Program 7: Write a menu driven program using switch case to do different arithematic operations,
showing use of break statement also
---------------------------------------------------

Topic 4: Loops(while, do while and for)

Program 1: WAP to calculate factorial of a number.


Program 2: WAP to check whather a number is prime or not?
#include <stdio.h>

int main() {
int n, i, isPrime = 1;

// get the number from the user


printf("Enter a positive integer: ");
scanf("%d", &n);

// check if the number is prime


for (i = 2; i <= n / 2; i++) {
if (n % i == 0) {
isPrime = 0;
break;
}
}

// print the result


if (isPrime)
printf("%d is a prime number.", n);
else
printf("%d is not a prime number.", n);

return 0;
}

Program 3: WAP to reverse a given number.


Program 4: WAP to print the table of any number.
Program 5: WAP to check whather number is pelindrome or not?
Program 6: WAP to check whather number is armstrong or not?
Program 7: WAP to show the use of goto, and continue statements.

Topic 5: Loops and Nested loops

Program 1: WAP to display following pattern:


*
**
***
****
*****
Program 2: WAP to display following pattern:
1
12
123
1234
12345

Program 3: WAP to display following pattern:


1
121
12321
1234321

#include <stdio.h>

int main() {
int rows, i, j, space, num;

printf("Enter the number of rows: ");


scanf("%d", &rows);

for(i = 1; i <= rows; i++)


{
num = 1;
space = rows - i;
for(j = 1; j <= space; j++)
{
printf(" ");
}
for(j = 1; j <= i; j++)
{
printf("%d", num);
num++;
}
num -= 2;
for(j = 1; j < i; j++)
{
printf("%d", num);
num--;
}
printf("\n");
}

return 0;
}
Program 4: WAP to display following pattern:
12345
2345
345
45
5
Program 5: WAP to display first 10 prime numbers.

#include <stdio.h>

int main() {
int count = 0, i, j, isPrime;

printf("First 10 prime numbers are: ");

// iterate over numbers from 2 to infinity


for (i = 2; count < 10; i++) {
isPrime = 1;

// check if i is prime
for (j = 2; j <= i / 2; j++) {
if (i % j == 0) {
isPrime = 0;
break;
}
}

// if i is prime, print it and increment count


if (isPrime) {
printf("%d ", i);
count++;
}
}

return 0;
}

Topic 6: 1 Dimenssional array

Program 1: WAP to store integer data in an array, and print the elements of the array:
Program 2: WAP to find the sum of all elements of an array.
Program 3: WAP to find the greatest and smallest number in the array.
Program 4: WAP to search a given item in an array.
Program 5: WAP to display the contents of the elements of array that are at odd/even positions.
Program 6: WAP to enter 10 different numbers in an array, then adding the numbers that are
divisible by 3 and displaying the result.

Topic 7: 2 Dimenssional array

Program 1: WAP to enter 3X3 array. Display the array in the form of a matrix. Then find the product
of the elements of the array that are divisible by 4.
Program 2: WAP to add two matrices.
Program 3: WAP to multiply two matrices.
Program 4: WAP to find the sum of diagonal elements of a square matrix.
Program 5: WAP to find the sum of opposite diagonal elemnts of a square matrix.
Program 6: WAP to find transpose of a matrix.

Topic 9: functions

Program 1: Write a menu driven program to show various arithematic operations using switch and
functions.
Program 2: WAP to find factorial of the number using functions.
Program 3: WAP to show the table of the number using functions.
Program 4: WAP to find whather a number is prime or not using functions.
Program 5: WAP to swap the value of two numbers using functions.
Program 6: WAP to display fibonnaci series using functions.

Topic 10: functions(call by value, call by reference)

Program 1: WAP to show the working of call by value and call by reference for sum of two
numbers.
Program 2: WAP to calculate the sum of all the elements of an array using functions.
Program 3: WAP to find the greatest and smallest from the elements of array using functions.
Program 4: WAP to calculate the sum of all elements of an array that are divisible by 5 and are
even.
Program 5: WAP to swap the values of two variables using call by value and call by reference.
(questions of series)

Topic 11: Recursion

Program 1: WAP to print your name 10 times using recursion.


Program 2: WAP to find factorial using recursion.
Program 3: WAP to display fibonnaci series using recursion.
Program 4: WAP to sum of all even numbers smaller than 100 using recursion.
Program 5: WAP to find whather a number is prime or not using recursion.

Topic 12: strings

Program 1: WAP to concatenate two strings.


Program 2: WAP to compare two strings.
Program 3: WAP to perform arithmetic operations on characters.
Program 4: WAP to calculate length of the string.
Program 5: WAP to copy a string.
Program 6: WAP to convert a string from uppercase to lowercase letters.
Program 7: WAP to find whather a string is palindrom or not.
Program 8: WAP to find number of occurances of “e” in a string, and replace “e” with “X”.
MID TERM

Topic 8: pointers

Program 1: WAP to print address of a variable along with its value.


Program 2: WAP to show accesing of array elements using pointers.
Program 3: WAP to illustrate the use of indirection operator.
Program 4: WAP to illustrate use of pointer in arithematic operations.
Program 5: WAP to show the use of pointers to compute the sum of all elemnts stored in array.

Topic 13: structures and unions

Program 1: WAP using structures to display the record of 4 employees of a company.


Program 2: WAP using unions to display the record of 4 employees of a company.
Program 3: WAP to compare two structures.
Program 4: WAP to store the record of a student containing name, rollnumber, class and marks in
three subjects of the student.(array within structure).
Program 5: using the structure in above program create an array of atleast 5 elements. (array of
structures).

You might also like