Posts

Showing posts from April 1, 2020

Getting string from gets() and find string length ( Chapter 1 Program 7 )

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /* 7. Write a program to enter text with gets() and display it     using printf() statement also find the length of the text */ #include<stdio.h> #include<conio.h> void main() { char string[99]; int length = 0; clrscr(); printf("Enter an string : ");   gets(string); printf("\n\nYour string is %s" , string ); while( string[length] != '\0' ) { length++; } printf("\n\nYour string length is %d ", length ); getch(); }

Maximum from two numbers Conditional Operator ( Chapter 1 Program 8 )

Image
Also visit our YouTube Channel Tech Eos     VISIT CHANNEL /*   8. Write a program to enter two numbers and find the smallest  out of them. Use conditional operator. */ #include<stdio.h> #include<conio.h> void main() { int number1 , number2 , maximum ; clrscr(); printf("\nEnter 1 number value : "); scanf("%d" , &number1); printf("\nEnter 2 number value : "); scanf("%d" , &number2); maximum = number1 > number2 ? number1 : number2 ; printf("\n\nMaximum number is  %d" , maximum); getch(); }