Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
46 views
20 pages
DocScanner Dec 14, 2023 12-01 PM
It's important you know..... Som.......
Uploaded by
123456789raman123456789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save DocScanner Dec 14, 2023 12-01 PM For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
46 views
20 pages
DocScanner Dec 14, 2023 12-01 PM
It's important you know..... Som.......
Uploaded by
123456789raman123456789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save DocScanner Dec 14, 2023 12-01 PM For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save DocScanner Dec 14, 2023 12-01 PM For Later
You are on page 1
/ 20
Search
Fullscreen
CC-1 LAB MANU: 4. Waite a Program to find groatest among throo numbers. Hinclude
= 03) .2if is the largest number.", n2); printf(’ else printf("%.2If is the largest number.", n3); + return 0; } 2. Write a Program to all arithmetic operation using switch case. #include
#include
int main) { . inta,b; int op; printi(" 4.Addition\n 2,Subtraction\n 3.Multiplication\n 4.Division\n’); printf("Enter the values of a & b: scanf("%ed %d", &,&b); printf(*Enter your Choice scanf("%d",&0p); switch(op) { case 1: printf¢'Sum of Yd and %d is : %d,a,b,a+b); break; case 2: printf("Difference of Yd and %d is : %d",a,b,a-t break; case 3: printf("Mul tion of %d and %d is : %d'",a,b,a*b); 7 | Jyoti Prakash Mohanta, Asst. Prof. of Computer Science, ‘Autonomous College, Balasorebroak; caso 4: rint{(’Division of Two Numbers is %6d :",9/9): brook; dofault print’ boat } rotur 0; } 3. Writo a Program to print the sum and product of digits of ter Your Correct Choice"); ‘an intogor. #include
int maing intn.nt; int dig, sum,pro; printf("inEnter any integer number scanf("%d",&n); nt=n; sum=0; Pro=1; while(n>0) { dig=n% 10; } Printf("\INSUM of Digits of Number [ %d ] : [ 96d ].\n"\n1 sum); Printf("\MPRODUCT of digits of Number [ %d ] : [ %d ].\n",n4,pro);, return 0; } 4, Write a Program to reverse a number. #include
int main() { int n, reverse=0, rem; Printf("Enter a number: "); scanf("%d", &n); while(n!=0) fi FT Serre 2 | Sveti Prakash Mohanta, Asst, Prof, of Computer Selence, FM Autonomous Collage, Balasoreromren%10; fovorsa=roverso"t0 tranny; at0; } a Rovorned Numbor: %¢c!revorso); rotum 0; 6, Write a Program to computo tho sum of tho first n torms of tho following sorlos: SA AMIZAMISHTUA sce #includa
Void main() { double numbor, sum = 0, |; prini((" ontar the number "); scanf("%i", &number); for (j= 1;1 <= number; I++) sum = sum + (1/1); if(== 1) printf("\n 1 +"); else if (i == number) printf(" (1.1 %If)", i); also printf(" (1 / %lf) +", 1); } printf("\n The sum of the given series is %.2If", sum); 6. Writo a Program to compute tho sum of tho first n torms of tho following sorios: S$ =1-243-446, include
/ifunction for creating the sum of the series up to Nth term int series_sum(int n) { If (9% 2==0) return (-(n/ 2)); else return ((n + 1) /2); } int main() { int n; f Computer Sclence, F.M Autonomous College, Balasore 3 | Jvotl Prakash Mohanta, Asst, ProfNin"); printf("Want some up to N terms?\nEnter the N term: scanf("%d", &n); printf(’Sum Is:%d", series_sum(n)); retum 0; 7. Write a function that checks whether a given string is Palindrome or not, Uy function to find whether the string entored by user Is Palindrome or not. #include
#include
int checkpalindrome(char *s) { return 1; else retumn 0; } int main() { char s[1000}; printf("Enter the string: gets(s); if(checkpalindrome(s)) printf('string is palindrome"); else printf(‘string is not palindrome’ 8. Write a function to find whether a given no. is prime or not. Use the same to generat! prime numbers less than 100. #include
int main { int i, Number, count; ‘Computer Science, F Q | Jyoti Prakash Mohanta, Asst. Prc Autonomous College, BalasorePrime Number from 1 to 100 aro: \n"); print for(Numbor # 1; Numbor = 100; Number) ( count #0; for 2 Ls Numbor/2; 14) i(Numborl #* 0) { count; brook; ) ) (count ## 0 && Numbor I= 1) { ) ) roturn 0; ) printt(" il ", Numbor); 9. Writo a Program to compute tho factors of agivon numbor. #includo
int maing) { int num, |; print("Entor a positive Intogor: "); scant(""al’, &um); print{("Factora of %d aro: *, num); for (Ie 1; 12 num; +4) { We (rum % 15 0) { prlntt("%el% 1); ) } roturn 0; 40, Writo a program to swap two numbors using macro. Hincludo
1/Dolino macro to swap wo numbors Hclotino SWAP(x, y) (x= y * x * y) int main() 5] “Voll Prakish Mohanta, Asst Prof, of Computor Selenee, F.M Autonomous Collego, BalasoreeH Int num4, num2; rintf("Enter any two number to swap: "): Scanf("%d%d", &umt, &num2); brint{("Values bofore swapping\n'); 2) Printf(’numt = %d, num2 = Yed\nin", num4, num2); SWAP(num1, num2); brintf("Values after swapping\n"); ‘ Printf(‘numt = %d, num2 = %dl\n", num4, num2); return 0; 11, Write a Program to print a triangle of stars as follows (take number of lines from Use), | #include
int main(y inti, space, rows, k = 0; Printf'Enter the number of rows: | scanf("%d", &rows); for (i= 4; 1 <= rows; +4i, k= 0) { for (space = 1; space <= rows - j; ++space) ( printf" } while (k I= 2*i-1) { printf"); +k; } printf("\n") } return 0; } 12. Write a Program to perform following actions on an array entered by the user: | a) Print the even-valued elements i 6 | svotl Prakash Mohanta, Asst. Prof. of Computer Science, FM Autonomous College, Balasoreb) Print the odd-valued olements ¢) Calculate and print the sum and average of the elements of array 4d) Print the maximum and minimum olement of array ) Remove the duplicates from the array f) Print the array in reverse order The program should present a menu to tho user and ask for one of the options. The menu Should also Include options to ro-enter array and to qult the program. Hinclude
#include
#include
void even();//function to check the even elements of the array void odd();//User defined function to check the odd elements of the array void sum_and_avg();/User defined function to find the sum and average of elements of the array void max_and_min();//User defined function to the maximum and minimum element of the array void remove_duplicates();//User defined function to remove duplicate elements of the array void reverse();//User defined function to reverse the array int main() { int option; char choice; dof {Displaying Menu options printf("n MENU, "; printf('(n 1. Print the even-valued elements of the array" printf(‘1n 2. Print the odd-valued elements of the array’); | printf("\n 3. Calculate and print the sum and average of the elements of array"); i printf("\n 4. Print the maximum and minimum element of array"); printf("\n 5. Remove the duplicates from the array"); | printf("in 6. Print the array in reverse order"); | printf("n 7. Exit’); printf("intn Enter Your Choice : scanf("%d", &option); switch(option) : { case 1: event); break; case 2: 7 | roti Prakash Mohanta, Asst. Prof. of Computer Scence, FM Autonomous College, Balasorecaso 3: ‘sum_and_avg()i break; case 4) max_and_min(); break; case &: : romove_duplicatos(); break; case 6: reverse(); break; case 7: printf("Exiting Program... exit(1); default: : printf("\n Invalid Choice I"); break; } ie "i print{(*Do you want to continue (Y/N)? "); choice=getch(); MDefining the function even) void even() { char op; int i, num,even=0; printf("\n Enter the size of an array : scanf("%d", &num); int array[num]; printi("\n Enter the elements of the array for (i= 0; i< num; i++) { scanf("%ed", &arraylil); } printf("in Even numbers in the array are for (i = 0; i < num; i++) { if (array{i] % 2 == 0) { even++; 8 | $voti Prakash Mohanta, Asst. Prof. of Computer Science, F:M Autonomous College, Balasoreprint(("%d W, arraylil); } joefining the function odd) void odd”) { char OP, int, num_odd=0; print((\n Enter the size of an array : scanf("%d", 8num); int arrayfnum|; printf("n Enter the elements of the array for (i < num; i++) scanf("%d", &arrayfi)); } printi(\n Odd numbers in the array are: for (i = 0; i < num; i++) if (array(i] % 2 != 0) { odd++; printi("%d W', arrayti); } } ? Defining the function sum_and_avg() void sum_and_avg() { char op; int size, i, sum = 0; printf("n Enter the size of the arrays : scant('%d", &size); int arr{size}; printf("\n Enter the elements of the array : for (i= 0;i< size; i++) { scant("%d", &artil); 99 | Jyoti Prakash Mohanta, Asst. 'M Autonomous College, Balasoresum += arr{i); } rintf(’n The sum of the array is : %d \n", sum); . printf("In. The average of the array is : %f", (float)sum / size); ) MDefining the function max_min() void max_and_min() { char op; inti, max, min, size; printf("\n Enter the size of the arrays : "); scanf("%d", &size); int arrfsize| printf('\n Enter the elements of the array : "); for(i=0; i<: itt) { scanf("%d", Barr[i)); } max = arr[Q}; min = arr{0}; for(i=1; icsize; i++) { iffarsf > max) { ris iffartti] < min) { min } } printf("\n Maximum element Printf("\n Minimum element = arti); %d\n", max); %d", min); U {Defining the function remove_duplicates. void remove_duplicates() { char op; inti j, k,n; printf("\n_ Enter array size: "); scanf("%d", &n); 10 | Joti Prakash Mohanta, Asst. Prof. of Computerint arta}: printf(\n_ Enter %d array element for(i =O;
=0; I~) { } } scanf(%d", Sarr); printf("%d", aril); 43. Write a Program that prints a table indicating the number of occurrences 4 alphabet in the toxt entered as a string. #include
#include
#include
struct detail { char ¢ int freq; int main() { struct detail s[26]; char string[100}, c; int i= 0, index; for (i= 0; 1 < 26; i++) { sfi.c=1+'a'; sfilfreq = 0; u printf(’Enter string: "); i=0; do { ¢ = getchar(); stringli+#] =o; if(c=="n) { 12 | svotl Prakash Mohanta, As .M Autonomous College, Balasorea break: 2 rtowerte) index=¢- sfindex] freqr+; ywhile (1); stringfi- 1] = 10% printThe string entered is: %a\n", string); paintsctreeerorrrrrerreeeeeeeentaCharactentFrequency\nterte veeeeeen): for (= 0; 1< 26; i++) { if (sfilfreq) { printf” %elt %dln", sf. sf freq); } } return 0; 14. Write a program that swaps two numbers using pointers. #include
int main0 { int x, y, *a, *b, temp; printf("Enter the value of x and yin"); scani("%d%d", &x, By); printf("Before Swapping\nx = %d\ny = %din", x, y);, asax, *a=temp; printf(‘After Swapping\nx = %d\ny = d\n’ retum 0; “ 45. Write a program in which a function is passed address of two variables and then alter its contents. #include
void swap(int *n1, int *n2); int main) vrakash Mohanta, Asst. Prof. of Computer Science, F.M Autonomous College, Balasoreintnum1; int numa; print{("Enter two values :"); scan{("%d%d",&numt &num print(("\nBefore swap:\n"); printt(" %¢\n",numt); printiCnum2 = 9%d",num2); Ml address of num1 and num2 is passed swap( &num1, &num2); printf("\n\nAfter swap:"); printf(\nnumt = %d\n", num); printf("num2 = %d", num2); Feturn 0; } void swap(int* n1, int n2) { int temp; 16. Write a program which takes the radius of a circle as input from the user, passes i: to another function that computes the area and the circumference of the circle and displays the value of area and circumference from the main() function. #include
const float Pl = 3.1415927; float area(float radius); float circum(float radius); void main() { float radius; printf("Enter radius of circle scanf("%f", &radius); printf("\nArea of circle : %.3fin", area(radius) printf("\nCircumference of circle : %.3f\n", circum(radius)); } float area(float ra { iS) return Pl * radius * radius; [a ] sv0ti Prakash Mohanta, Asst. Prof. of Computer Science, FM Autonomous College, Balasorehae curate) goat (eturn 2* PL* radius; ) am to find sum : Wi ee etioe and average of n olom tho user. To write allocat jonts entered by tho u! 47. Sproaans allocate memory dynamically using malloc() ealloc( } functions. do
incl Hing ido
incl wind { inti int count int "ars int sum = 05 print("Enter the total numberof elements you want to enter :"); seant("%d", &count);, ' fir (int *Jmalloc(count * sizeof{int)); for i= O11 < count; i+*) print(("Enter element %d :", (i+ 1)); seant("%d", arr + i); sum += “(arr + i); prnc\asum of %d number is %d \n",count, sum); printf(\n Average of Sed number is %f \n’,count,(loat)sum/count); free(ar); return 0; } 48, Write a menu driven program to perform following operations on strings: a) Show address of each character in string b) Concatenate two strings without using strcat function. c) Concatenate two strings using streat function. 4d) Compare two strings e) Calculate length of the string (use pointers) f) Convert all lowercase characters to uppercase g) Convert all uppercase characters to lowercase i) Calculate number of vowels i) Reverse the string #include
#include
#include
int main() { [TE | iat Prakash Mohanta, Asst. rot of Computer Scence, FM Autonomous College, Balasorechar str1{20},str2[20].c int chin; char * do print(c’n\n\tMENU"), printic\n— An"); : print((':Show address of each character in string"): printf("n2:Concatenate two strings without using str printf(’\n3:Concatenate two strings using printf("\n4:Compare two Strings"); printf(’\n5:Calculate length of the string! printf(\né:Convert all lowercase characters © printf(\n7:Convert all uppercase characters | printf("In8:Calculate number of vowels"): printf("in9:Reverse the string"); printf("\nt0:Exit’); printf("\n printf("\nEnter your choice: scanf("%d",&ch); c= getchar(); to uppercase”): 5 lowercase"): —\ switeh(ch) { case 1: printi("Enter a String: scanf("%[Nn}",ste4}; nestrlen(strt); for (i= 0; ien; i+*) j printf("\nAddress of %c ii mur strip, ester fl): break; case 2: printf(’Enter 1st Strin scanf(’%[Mn}",stet); o = getchar();/ldummy function to read new line character printf("Enter 2nd String: "); scant("%6f"tn]",str2); for(i=0; strt[i]!=\0% +44); for(j=0; strfi=0%s +41, ++) { strtfi]=str2{; a} strtfi printf("\nOutpt s",stt1); break; —_—___—— Sriaonanta, Asst. Prof of Computer Science, F-M Autonomous College, Balasorecase 3: print(('Enter 1st String scanf(’6[*\n}",strt): = getchar()v/dummy function to read new line character printf("Enter 2nd String: "); scanf(’%[*\n}',str2); stroat(str1,str2); printf("\ninString After Goncatenation : Ysin\n',strt); break; case 4: printf('Enter 1st String: "); scanf("%["nI",str1); ¢ = getchar();//dummy function to read new line character printf(’Enter 2nd String: scanf("%f"\n]",str2); printf(\n\nStrings are Same,\n\n"); y else { printf("\nlnStrings are Not Same.\n\n"); } break; case 5: printf("Enter a String’ scant("%[Mn}",str4); -&str1[0]; while (*p I= "0 { is; pet } printf(’\n\nLength of the sttring is: %d.\nin',); break; case 6: scanf("%[\n]",str1); for(i=0;i<=strlen(str1);i++) { . if(str1f>=6588str1 [i 17 | jvoti Prakash Mohanta, Asst. Prof. of Computer Science, F.M Autonomous College, Balasore— ONT stetfi}=trti}+32; Prin((\NINLower Caso String to: Ybs",atrl); break, case 7: Print{("Enter String; ") Scan{("%[A\n}",strt); i =strlen(strt);i++) i(Str1[]>=978.astr4[i}<=122) : strifiJ=stet[i}-32; Print{("\nUpper Case String is: %s",str1); break; while (str1fi] = \0') { if (Stet 'o' [| str1 [ij printf("Number of vowels in the string: %d", n); break; case 9: printf("Enter String scanf("%[“in}",str strrev(str1); printf("Reverse string : %sin\n"str1); break; case 10: exit(0); break; default: printf("Invalid Input. Please Enter valid Input.\n\n "); } Jwhile(ch 0); 18 | ‘Jyoti Prakash Mohanta, Asst. Prof. of Computer Science, F.M Autonomous College, Balasoreant 2.03% it enter the size of first array %) ment Moc" B11), peninenter the size of second array"); Ecant('%a" 82); roent*n2; vntf(\nenter the first sorted array elements" int alnt},bIn2},c[n3], Array Declaration fonfeoientsit+) Array initialized © ant" Bali; ofil=alil: } intkent; print("nEnter the second sorted array elements"; je0,i
#include
main) { char ch, source_file[20}, target_file[20}; FILE *source, “target; printi(’Enter name of file to copy\n"); gets(source_file); open(source_file, "r"); ULL ) printi('Press any key to exit...\n exit(EXIT_FAILURE); } print{(’Enter name of target file\n");, gets(target_file); target = fopen(target_file, "Ww"); if( target == NULL ) { oe felose(source); printf(’Press any key to e: exit(EXIT_FAILURE); , whilet (ch = fgete(source) ) != EOF ) fpute(ch, target); print{(’File copied successfully.\n’ fclose(source); felose(target); return 0; } : 20 | Wvoti Prakash Mohanta, Asst. Prof. of Computer Science, F.M Autonomous College, Balasore
You might also like
C Lab 1st Internal Examination For EEE 1st Year - 001
PDF
No ratings yet
C Lab 1st Internal Examination For EEE 1st Year - 001
30 pages
1) How To Print Below Pattern?
PDF
No ratings yet
1) How To Print Below Pattern?
28 pages
The Sum and Average of N Number of Marks of A Student
PDF
No ratings yet
The Sum and Average of N Number of Marks of A Student
28 pages
Anchal (Ds Lab Manual)
PDF
No ratings yet
Anchal (Ds Lab Manual)
100 pages
Am - En.u4cse20370 Lab 6
PDF
No ratings yet
Am - En.u4cse20370 Lab 6
27 pages
Assignment-Ii Computer Programming
PDF
No ratings yet
Assignment-Ii Computer Programming
52 pages
#Include #Include #Include Void Main (
PDF
No ratings yet
#Include #Include #Include Void Main (
47 pages
C Lab Manual
PDF
No ratings yet
C Lab Manual
40 pages
Programming Through 'C' Language
PDF
No ratings yet
Programming Through 'C' Language
91 pages
C Language
PDF
No ratings yet
C Language
70 pages
CPPM
PDF
100% (2)
CPPM
10 pages
Fundamental Computer & Programing in C: Program File OF
PDF
No ratings yet
Fundamental Computer & Programing in C: Program File OF
27 pages
EC8381 Fundamentals of Data Structures in C Laboratary
PDF
100% (3)
EC8381 Fundamentals of Data Structures in C Laboratary
88 pages
C++ Coding Examples 2
PDF
No ratings yet
C++ Coding Examples 2
14 pages
C Program Assignment
PDF
No ratings yet
C Program Assignment
20 pages
C Programs
PDF
No ratings yet
C Programs
45 pages
C Program Output
PDF
No ratings yet
C Program Output
39 pages
C Lab Report
PDF
100% (2)
C Lab Report
45 pages
C Full Programs
PDF
100% (1)
C Full Programs
26 pages
Technical (C)
PDF
No ratings yet
Technical (C)
9 pages
Operating System Lab (K)
PDF
No ratings yet
Operating System Lab (K)
67 pages
C Popupdated
PDF
No ratings yet
C Popupdated
14 pages
CS Lab 2
PDF
No ratings yet
CS Lab 2
7 pages
C & C++ Sem 2 Practical Solutions
PDF
No ratings yet
C & C++ Sem 2 Practical Solutions
13 pages
Practical Assignment 1 (A)
PDF
No ratings yet
Practical Assignment 1 (A)
25 pages
Sep Bca - C Lab Manual
PDF
No ratings yet
Sep Bca - C Lab Manual
22 pages
2 CP
PDF
No ratings yet
2 CP
10 pages
C Programming
PDF
No ratings yet
C Programming
9 pages
C File
PDF
No ratings yet
C File
37 pages
Clabfile
PDF
No ratings yet
Clabfile
25 pages
Cool
PDF
No ratings yet
Cool
68 pages
C File Chentapak Merged Deleted
PDF
No ratings yet
C File Chentapak Merged Deleted
24 pages
Bx4002 - PSP Program
PDF
No ratings yet
Bx4002 - PSP Program
29 pages
C Questions
PDF
No ratings yet
C Questions
19 pages
Ds Sem1 Record
PDF
No ratings yet
Ds Sem1 Record
35 pages
PST LAB Mannual
PDF
No ratings yet
PST LAB Mannual
15 pages
CP Assignments
PDF
No ratings yet
CP Assignments
19 pages
Lab Report - Leading University
PDF
No ratings yet
Lab Report - Leading University
15 pages
C Assignment 1st Year
PDF
No ratings yet
C Assignment 1st Year
19 pages
Department of Computer Science & Engineering: Programming For Problem Solving
PDF
No ratings yet
Department of Computer Science & Engineering: Programming For Problem Solving
109 pages
C Lab Assignment
PDF
No ratings yet
C Lab Assignment
11 pages
Week 1 C Lab
PDF
No ratings yet
Week 1 C Lab
6 pages
EC CODING New - Merged
PDF
No ratings yet
EC CODING New - Merged
66 pages
C Prog Part A and B 27 Progs
PDF
No ratings yet
C Prog Part A and B 27 Progs
23 pages
C Program Lab Manual
PDF
No ratings yet
C Program Lab Manual
24 pages
Lab 5
PDF
No ratings yet
Lab 5
6 pages
All Prgrams FPL
PDF
No ratings yet
All Prgrams FPL
20 pages
Bca C Lab Manual 2024-28
PDF
No ratings yet
Bca C Lab Manual 2024-28
22 pages
Internship Assignments C Programming
PDF
No ratings yet
Internship Assignments C Programming
5 pages
Part B Practice Programs v1
PDF
No ratings yet
Part B Practice Programs v1
13 pages
Lab Manual 4. Array
PDF
No ratings yet
Lab Manual 4. Array
6 pages
C To Python Programs
PDF
No ratings yet
C To Python Programs
4 pages
Program Bài Tập
PDF
No ratings yet
Program Bài Tập
7 pages
BCA Data Structure Lab Manual
PDF
No ratings yet
BCA Data Structure Lab Manual
64 pages
Document
PDF
No ratings yet
Document
31 pages
Gauravsinghjoon C File
PDF
No ratings yet
Gauravsinghjoon C File
42 pages
PROGRAMS
PDF
No ratings yet
PROGRAMS
35 pages