×
Hard work beats talent when talent doesn’t work hard.
--Your friends at LectureNotes
Close

Lab Manuals for Programming in C - C By MOSHECK MENTA

  • Programming in C - C
  • Practical
  • 360 Views
  • 21 Offline Downloads
  • Uploaded 3 months ago
Mosheck Menta
Mosheck Menta
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

I-YEAR-I-SEM-B.Sc-Computer Science CODE-BS106 C--LAB-MANUAL EXERCISE-1 1. Write a program to find the largest two (three) numbers using if and conditional operator:1. a)if condition using 2 numbers:Program:#include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter a,b values are :\n"); scanf("%d%d",&a,&b); if(a>b) { printf("a value is largest : %d",a); } else { printf("b value is largest :%d",b); } getch(); } Output:- Govt. Degree College-Bheemgal-Telangana-University Page 1

Text from page-2

I-YEAR-I-SEM-B.Sc-Computer Science CODE-BS106 C--LAB-MANUAL 1. b) conditional operator using 2 numbers:Program:#include<stdio.h> #include<conio.h> void main() { int a,b,z; clrscr(); printf("Enter a,b values are :\n"); scanf("%d%d",&a,&b); z=(a>b) ? a : b; printf("largest number is :%d",z); getch(); } Output:- 1. c) if condition using 3 numbers:Program:# include <stdio.h> #include<conio.h> void main() { int a, b, c,; Govt. Degree College-Bheemgal-Telangana-University Page 2

Text from page-3

I-YEAR-I-SEM-B.Sc-Computer Science CODE-BS106 C--LAB-MANUAL clrscr(); printf("Enter three numbers : ") ; scanf("%d %d %d", &a, &b, &c) ; if(a>b) { printf("a is largest : %d",a); } else if(b>c) { printf("b is largest : %d",b); } else { printf("c is largest : %d",c); } getch(); } Output:- 1. d) conditional operator using 3 numbers:Program:# include <stdio.h> #include<conio.h> void main() Govt. Degree College-Bheemgal-Telangana-University Page 3

Text from page-4

I-YEAR-I-SEM-B.Sc-Computer Science CODE-BS106 C--LAB-MANUAL { int a, b, c, z ; clrscr(); printf("Enter three numbers : ") ; scanf("%d %d %d", &a, &b, &c) ; z = a > b ? (a > c ? a : c) : (b > c ? b : c) ; printf("\nThe largest number is : %d", z) ; getch(); } Output:- Govt. Degree College-Bheemgal-Telangana-University Page 4

Lecture Notes