React Components Explained: Types, Features and Examples for Beginners

Image
Learn Functional and Class Components in React with Practical Examples. 1. Introduction to React Components React is a popular JavaScript library used to build modern and interactive user interfaces. It helps developers create websites and web applications that are fast, flexible, and easy to maintain. One of the most important concepts in React is Components. React Components make it possible to divide a large user interface into smaller and reusable parts. For example, a website may contain a Header, Navigation Bar, Sidebar, Main Content, and Footer. Instead of writing all the code in a single file, developers can create separate components for each section. This approach makes website development more organized and understandable. Beginners can learn React more easily by understanding how components work. 2. What Are React Components? React Components are independent and reusable pieces of a user interface. They are one of the basic building blocks of React applications....

C Program To Print Day of Week using If else case in switch case

c program     

https://webdesigningtheory.blogspot.com/

  C Program To Print Day of Week using  switch case

Example :-


#include<stdio.h>
#include<conio.h>
void main()
{
int num;
clrscr();
printf("enter a number between 1 to 7 :-");
num=getchar ()-'0';
if (num>=1&& num<=7)
{
switch(num)
{
case 1:
printf("monday \n");
break;
case 2:
printf("tuesday \n");
break;
case 3:
printf("wednesday \n");
break;
case 4:
printf("Thursday \n");
break;
case 5:
printf("Friday \n");
break;
case 6:
printf("Saturday \n");
break;
case 7:
printf("Sunday \n");
break;}
}
else{
printf("enter number between 1 to 7");
}
getch();

}



C Program To Print Day of Week using  switch case

Explain Program

Step :1

#include <stdio.h>

 input-output use printf() & scanf() function.

Step :2

int main()

 point of the C program. All execution .

Step :4

int num;

  • Declares an integer variable num.
  • It will store the number the user enters.

Step :5

printf("enter a number between 1 to 7 :-");

  • Displays message to the user to input a number between 1 and 7.

Step :6

num = getchar() - '0';

  • getchar() reads one character from the keyboard (like '1', '2', etc.).
  • Subtracting '0' converts the character to an integer.


Step :7

if (num >= 1 && num <= 7)

  • Checks whether the entered number is between 1 and 7.
  • If true, enter the switch block.
  • If false, go to the else block and print an error message.

Step :8

switch(num)

  • A multi-way branch statement.
  • Based on the value of num, it goes to the correct case.

Step :9

case 1: printf("monday \n"); break;

case 2: printf("tuesday \n"); break;

case 3: printf("wednesday \n"); break;

case 4: printf("Thursday \n"); break;

case 5: printf("Friday \n"); break;

case 6: printf("Saturday \n"); break;

case 7: printf("Sunday \n"); break;

Step :10

else

  • Runs if the user enters something not between 1 and 7.
  • Displays the message: "enter number between 1 to 7".

Output :-

Enter a number between 1 ro 7 :-  5
Friday 

Related post :-

javascript do while loop

Project navigation bar page

php number increasing reverse pyramid


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples