Thursday, 27 May 2021

C Programs related if else or loop related mostly

 

/*write a program to check whether
it is alphabet ,digit , special character*/
#include<stdio.h>
void main()
{
int a// a is a integer types
char ch// ch is a character types
printf("Enter any character of keyboard:");
scanf("%d%c",&a,&ch);
if(a>=0)
printf("answer is a digit");

else
{
    if(ch>='a'&&ch<='z')
printf("answer is a lower alphabet");
else
{
    if(ch=='/'||ch=='*'||ch=='-'||ch=='+'||ch=='%'||ch=='$'||ch=='&'||ch=='*'||ch=='@'||ch=='!'||ch=='#'||ch=='^'||ch=='=')
    printf("answer is a special character");

    else
    printf("answer is a upper alphabet");
}

}

}




#include <stdio.h>

int main()
{
    int i, end;

    /*
     * Input a number from user
     */
    printf("Print all natural numbers from 1 to : ");
    scanf("%d", &end);

    /*
     * Print natural numbers from 1 to end
     */
    i=1;
    while(i<=end)
    {
        printf("%d\n", i);
        i++;
    }

    return 0;
}


/*write a program to check birthday
boy name by putting input  of birth year*/
#include<stdio.h>
void main()
{
int year;
printf("Enter the year of a birth:\n");
scanf("%d",&year);
if(year==1971)
    printf("Happy Birthday Dad");
else{
    if(year==1975)
        printf("Happy Birthday Mom");
    else{
        if(year==1992)
            printf("Happy Birthday Bhupendra");
            else{
                if(year==1995)
                    printf("happy Birthday maya");
                else{
                    if(year==2000)
                    printf("Happy birthday Upendra");
                    else{
                        if(year==2005)
                            printf("Happy Birthday nitesh");
                        else
                            {
                                if(year==2009)
                                    printf("happy Birthday chhottu");
                                else
                                    printf("User Input is undefined");
                            }

                    }

                }
            }

    }
}
}


//write a program to interchange contents
//author: upwndra ydav date:10/28/2020
#include<stdio.h>
void main()
{
int C,D//C&D are two numbers
printf("Enter the number C&D:\n");
scanf("%d%d",&C,&D);
printf("Interchanged Contents is %d\t%d",D,C);








}



. . . . .
struct student
{
 char name[20];
 int roll_no;
}*p;

p = (struct student*) calloc(5sizeof(struct student) );
. . . . .


/* write a program to check whether the alphabet is vowel or consonant */

#include<stdio.h>
void main()
{char ch;
printf("Enter a alphabet character :");
scanf("%c",&ch);
if(ch>='a'&&ch<='z')
{
    printf("alphabet is a lower case");
}
else if(ch>='A'&&ch<='Z')
{
    printf("alphabet is a upper case");
}
else
{
    printf("it is not a alphabet");
}
}



//write a program to find the log values of any number
//author:upendra
#include<stdio.h>
#include<math.h>
void main()
{
int x;
float sin_val;
printf("Enter the  number to find their sin  value:\n");
scanf("%d",&x);
sin_val=sin(x);
printf("sin value is %f",sin_val);







}


// logical operator exp
//author:upendra
#include<stdio.h>
void main()
{
int a,b,c,d,e,f,result;
printf("Note: 1=True and 0=False\n");
printf("enter the number to check logical:\n");
scanf("%d%d%d%d",&a,&b,&c,&d);
e=a>b;
f=c<d;
result=!(e&&f);
printf("Result is %d",result);








}


//write a program to find avg marks of student and percentage of student
//authors:upendra yadav date:10/27/2020
#include<stdio.h>
void main()
{
int sub1=100,sub2=100,sub3=100,sub4=100,sub5=100// sub-subjects marks
int avg_mark,perc_mark;
printf("Enter the marks of a student:\n");
scanf("%d%d%d%d%d",&sub1,&sub2,&sub3,&sub4,&sub5);
avg_mark=(sub1+sub2+sub3+sub4+sub5)/5;
perc_mark=avg_mark;
printf("avg_mark is %d\n",avg_mark);
printf("perc_mark is %d%%\n",perc_mark);






}


/* write a program to find
percentage and division of mark enter by
user*/
#include<stdio.h>
void main()
{
int n1,n2,n3,n4,n5,perc;
printf("Enter the marks of the subject:\n");
scanf("%d%d%d%d%d",&n1,&n2,&n3,&n4,&n5);
perc=(n1+n2+n3+n4+n5)/5;
if(perc>=60)
printf("division is frist grade");
else
{if(perc>=50&&perc<=60)
printf("division is a second grade");
else{
if(perc>=40&&perc<=50)
printf("division is third grade");
else
{if(perc>=35&&perc<=40)
printf("just pass");
else
printf("fail");}}
}
}


//write a program to find max blw 10 numbers
//author:upendra yadav
#include<stdio.h>
void main()
{
int n1,n2,max;
printf("enter the numbers to find maximum :\n");
scanf("%d%d",&n1,&n2);
max=(n1>n2)?n1:n2;
printf("max is %d",max);


}


//write a program to find the maximum btw two numbers
//author:upendra yadav date :10/29/2020
#include<stdio.h>
void main()
{
int num1,num2;
printf("Enter the two numbers in input :\n");
scanf("%d%d",&num1,&num2);
if(num1>num2)
printf("Answer is %d",num1);
else
{
if(num2>num1)
printf("Answer is %d",num2);
else
{
printf("Answer is %d",num1);     }

}






}



//write a program using ternary operatoe
#include<stdio.h>
void main()
{
int num1,num2,max;
printf("Enter the input of two number:\n");
scanf("%d%d",&num1,&num2);
max=(num1>num2)?num1:num2;
printf("greater number is %d and %d is %d",num1,num2,max);



}



/* write a program to find no of a days in a
month*/
#include<stdio.h>
void main()
{
int m; // m is a month no (number)
printf("Enter the month no:");
scanf("%d",&m);
if(m==1)
printf("31 days");
else
{
if(m==2)
printf("28 days or 29 days is leap year");
else{
if(m==3)
printf("31 days");
else{
    if(m==4)
        printf("30 days");
    else{
        if(m==5)
            printf("31 days");
            else{
                if(m==6)
                    printf("30 days");
                else{
                    if(m==7)
                        printf("31 days");
                    else{
                        if(m==8)
                            printf("31 days");
                        else{
                            if(m==9)
                                printf("30 days");
                            else{if(m==10)
                                printf("31 days");
                                else{
                                    if(m==11)
                                        printf)("30 days");

                                }
                            }
                        }
                    }
                }
            }
    }

}
}
}


/*write a program to find month no corresponds
to which months name*/
#include<stdio.h>
void main()
{
int m; // month no of month
printf("Enter the month number:");
scanf("%d",&m);
if(m==1)
printf("january");
else
{
if(m==2)
printf("febuary");
else
{
if(m==3)
printf("march");
else
{
    if(m==4)
        printf("april");
    else{
        if(m==5)
        printf("may");
        else
        {
            if(m==6)
                printf("june");
            else
            {
                if(m==7)
                    printf("july");
                else{
                     if(m==8)
                      printf("august");
                      else
                        {
                            if(m==9)
                                printf("september");
                            else
                            {
                                if(m==10)
                                    printf("october");
                                else{
                                    if(m==11)
                                        printf("november");
                                    else{
                                        if(m==12)
                                            printf("december");
                                    }
                                }
                            }
                        }
                       }
            }
        }
    }
}
}
}
}



// Play an AVI using the MSvfw32.lib
// in the case of Dev-C++ link with libmsvfw32.a via
// Project>>Project Options>>Parameters>>Add Lib>>libmsvfw32.a
// created via BCX generated C code then modified for Dev-C++
// (actually-Dev C++ is the IDE for the GNU GCC/G++ compiler)
// a Dev-C++ tested Windows Application by vegaseat 21nov2004

#include<stdio.h>
#include<windows.h>
#include<vfw.h>

#define ID_MCIFrame 0
#define ID_MENU1 9001
#define ID_MENU2 9002
#define ID_MENU3 9003

static HINSTANCE BCX_hInstance;
static int BCX_ScaleX;
static int BCX_ScaleY;
static char BCX_ClassName[2048];
static HANDLE ghInst;
static HWND Form1;
static HWND MCIFrame;
static HMENU MainMenu;
static HMENU FileMenu;
static OPENFILENAME OpenFileName;
static char szFile[2048];
static char szFileTitle[2048];

#define Show(WindowRedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SH OW);

HWND BCX_Form(char,int=0,int=0,int=250,int=150,int=0,int=0);
void BCX_Set_Form_Color (HWND,COLORREF);
void Center (HWND,HWND=0,HWND=0);
char BCX_TmpStr(size_t);
char str (double);
char curdir (void);

void FormLoad (void);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int InitOpenFileName (void);
int PopFileOpenDlg (HWND, char , char );
BOOL AddMenu (HWND);


// standard Windows Graphical User Interface main
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR CmdLine,int CmdShow)
{
WNDCLASS Wc;
MSG Msg;
// *****************************
strcpy(BCX_ClassName,"MCI_demo1");
// ************************************
// Scale Dialog Units To Screen Units
// ************************************
RECT rc = {0,0,4,8};
MapDialogRect (NULL,&rc);
BCX_ScaleX = rc.right/2;
BCX_ScaleY = rc.bottom/4;
BCX_hInstance = hInst;
// ******************************************************
Wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
Wc.lpfnWndProc = WndProc;
Wc.cbClsExtra = 0;
Wc.cbWndExtra = 0;
Wc.hInstance = hInst;
Wc.hIcon = LoadIcon(NULL,IDI_WINLOGO);
Wc.hCursor = LoadCursor(NULL,IDC_ARROW);
Wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
Wc.lpszMenuName = NULL;
Wc.lpszClassName = BCX_ClassName;
RegisterClass(&Wc);

FormLoad();
// event message loop
while(GetMessage(&Msg,NULL,0,0))
{
HWND hActiveWindow = GetActiveWindow();
if (!IsWindow(hActiveWindow) || !IsDialogMessage(hActiveWindow,&Msg))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
}
return Msg.wParam;
}


// circular storage, hold the memory leaks to a minimum
char *BCX_TmpStr (size_t Bites)
{
static int StrCnt;
static char *StrFunc[2048];
StrCnt=(StrCnt + 1) & 2047;
if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(cha r));
}


char *str (double d)
{
register char *strtmp = BCX_TmpStr(16);
sprintf(strtmp,"% .15G",d);
return strtmp;
}


char *curdir (void)
{
register char *strtmp = BCX_TmpStr(2048);
GetCurrentDirectory (1024,strtmp);
return strtmp;
}


// center the window form on the screen, optional, for looks
void Center (HWND hwnd, HWND Xhwnd, HWND Yhwnd)
{
RECT rect, rectP;
int x, y, width, height;
int screenwidth, screenheight;
if(Xhwnd==0)
{
RECT DesktopArea;
RECT rc;
SystemParametersInfo(SPI_GETWORKAREA,0,&Deskto pArea,0);
GetWindowRect(hwnd,&rc);
SetWindowPos(hwnd,HWND_TOP,
((DesktopArea.right-DesktopArea.left)-(rc.right-rc.left))/2+
DesktopArea.left,((DesktopArea.bottom-DesktopArea.top)-
(rc.bottom-rc.top))/2 + DesktopArea.top,0,0,SWP_NOSIZE);
return;
}
GetWindowRect (hwnd,&rect);
GetWindowRect (Xhwnd,&rectP);
width = rect.right-rect.left;
x = ((rectP.right-rectP.left)-width)/2 + rectP.left;
if (Yhwnd==NULL)
{
height = rect.bottom-rect.top;
y = ((rectP.bottom-rectP.top)-height)/2 + rectP.top;
}
else
{
GetWindowRect(Yhwnd,&rectP);
height = rect.bottom-rect.top;
y = ((rectP.bottom-rectP.top)-height)/2+rectP.top;
}
screenwidth = GetSystemMetrics(SM_CXSCREEN);
screenheight = GetSystemMetrics(SM_CYSCREEN);
if ((x<0))
x=0;
if ((y<0))
y=0;
if ((x+width>screenwidth))
x = screenwidth-width;
if ((y+height>screenheight))
y = screenheight-height;
MoveWindow (hwnd, x, y, width, height, FALSE);
}


// create the windows form
HWND BCX_Form(char *Caption, int X, int Y, int W, int H, int Style, int Exstyle)
{
HWND A;
// assigne default style if none given
if (!Style)
{
Style= WS_MINIMIZEBOX |
WS_SIZEBOX |
WS_CAPTION |
WS_MAXIMIZEBOX |
WS_POPUP |
WS_SYSMENU;
}
A = CreateWindowEx(Exstyle,BCX_ClassName,Caption,
Style,
X*BCX_ScaleX,
Y*BCX_ScaleY,
(4+W)*BCX_ScaleX,
(12+H)*BCX_ScaleY,
NULL,(HMENU)NULL,BCX_hInstance,NULL);
SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObj ect(DEFAULT_GUI_FONT),
(LPARAM)MAKELPARAM(FALSE,0));
return A;
}


// color, why not
void BCX_Set_Form_Color (HWND hWnd, COLORREF Kolor)
{
HBRUSH hbr=CreateSolidBrush(Kolor);
DeleteObject((HBRUSH)SetClassLong(hWnd,GCL_HBRBACK GROUND,(DWORD)hbr));
InvalidateRect (hWnd,NULL,TRUE);
}


// the details - corner coordinates,width,height,title
void FormLoad (void)
{
Form1=BCX_Form("MCI Demo",0,0,197,170);
SetClassLong(Form1,GCL_STYLE,GetClassLong(Form1,GC L_STYLE)|CS_DBLCLKS);
BCX_Set_Form_Color(Form1,RGB(0,0,0));
// Now create the MCIWnd
MCIFrame=MCIWndCreate(Form1,(HINSTANCE)ghInst,WS_C HILD|WS_VISIBLE|MCIWNDF_NOOPEN|MCIWNDF_NOTIFYALL," ;");
AddMenu(Form1);
Center(Form1);
Show(Form1);
}


// event message handler
LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
static char s[2048];
memset(&s,0,sizeof(s));
static char mstr[2048];
memset(&mstr,0,sizeof(mstr));
static char mstr1[2048];
memset(&mstr1,0,sizeof(mstr1));
while(1)
{
if (Msg==WM_CREATE)
{
return 0;
break;
}
if (Msg==WM_COMMAND)
{
if (LOWORD(wParam)==ID_MENU2)
{
MCIWndClose(MCIFrame);
InitOpenFileName();
PopFileOpenDlg(Form1,szFile,szFileTitle);
if(strlen(szFile)>0)
{
MCIWndOpen(MCIFrame,szFile,0);
}
return 0;
}
if(LOWORD(wParam)==ID_MENU3)
{
MCIWndClose(MCIFrame);
ExitProcess(0);
}
break;
}
if (Msg==MCIWNDM_NOTIFYMODE)
{
while(1)
{
if ((long)lParam==MCI_MODE_NOT_READY)
{
SetWindowText(Form1,"Not Ready");
break;
}
if ((long)lParam==MCI_MODE_PAUSE)
{
SetWindowText(Form1,"Paused");
break;
}
if ((long)lParam==MCI_MODE_PLAY)
{
SetWindowText(Form1,"Playing");
break;
}
if ((long)lParam==MCI_MODE_STOP)
{
SetWindowText(Form1,"Stopped");
break;
}
if ((long)lParam==MCI_MODE_OPEN)
{
SetWindowText(Form1,"Opening");
break;
}
if ((long)lParam==MCI_MODE_RECORD)
{
SetWindowText(Form1,"Recording");
break;
}
if ((long)lParam==MCI_MODE_SEEK)
{
SetWindowText(Form1,"Seeking");
}
break;
}
break;
}
if (Msg==MCIWNDM_NOTIFYMEDIA)
{
SetWindowText(Form1,(LPSTR)lParam);
break;
}
if (Msg==MCIWNDM_NOTIFYPOS)
{
SetWindowText(Form1,str(MCIWndGetPosition(MCIFrame )));
break;
}
if (Msg==MCIWNDM_NOTIFYERROR)
{
SetWindowText(Form1,"MCI ERROR");
break;
}
if (Msg==WM_PAINT)
{
// The VideoWindow is restricted to a ratio of 4:3 here
break;
}
if (Msg==WM_SIZE)
{
static WORD Basedsp;
memset(&Basedsp,0,sizeof(Basedsp));
static WORD Cntr;
memset(&Cntr,0,sizeof(Cntr));
Basedsp=(HIWORD(lParam)-20)/3;
Cntr=(LOWORD(lParam)-(Basedsp*4))/2;
MoveWindow(MCIFrame,Cntr,0,(Basedsp*4),HIWORD(lPar am),TRUE);
// Don't forget to close opened Files
break;
}
if (Msg==WM_CLOSE)
{
MCIWndClose(MCIFrame);
DestroyWindow(Form1);
return 0;
break;
}
if (Msg==WM_DESTROY)
{
MCIWndClose(MCIFrame);
PostQuitMessage(0);
return 0;
}
break;
}
// tidy up and exit program
if (Msg==WM_DESTROY)
{
UnregisterClass(BCX_ClassName,BCX_hInstance);
PostQuitMessage(0);
}
return DefWindowProc(hWnd,Msg,wParam,lParam);
}


// tons of options for the neat file dialog box
int InitOpenFileName (void)
{
*szFile=0;
*szFileTitle=0;
OpenFileName.lStructSize=sizeof(OPENFILENAME);
OpenFileName.hwndOwner=MCIFrame;
OpenFileName.hInstance=(HINSTANCE)ghInst;
OpenFileName.lpstrFilter =
"Avi Files (*.AVI)\0*.avi\0All Files(*.*)\0*.*\0\0";
OpenFileName.lpstrCustomFilter=NULL;
OpenFileName.nMaxCustFilter=0;
OpenFileName.nFilterIndex=0;
OpenFileName.lpstrFile=szFile;
OpenFileName.nMaxFile=MAX_PATH;
OpenFileName.lpstrFileTitle=szFileTitle;
OpenFileName.nMaxFileTitle=MAX_PATH;
OpenFileName.lpstrInitialDir=curdir();
OpenFileName.lpstrTitle=NULL;
OpenFileName.nFileOffset=0;
OpenFileName.nFileExtension=0;
OpenFileName.lpstrDefExt="*.avi";
OpenFileName.lCustData=0L;
OpenFileName.Flags=OFN_SHOWHELP|OFN_PATHMUSTEXIST| OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
OpenFileName.lpfnHook=NULL;
OpenFileName.lpTemplateName=NULL;
return 0;
}


int PopFileOpenDlg (HWND Form1, char *szFile, char *szFileTitle)
{
OpenFileName.lpstrTitle="Open File";
OpenFileName.hwndOwner=MCIFrame;
OpenFileName.lpstrFile=szFile;
OpenFileName.lpstrFileTitle=szFileTitle;
OpenFileName.Flags=OFN_EXPLORER|OFN_CREATEPROMPT;
return GetOpenFileNamePreview(&OpenFileName);
}


BOOL AddMenu (HWND hwndOwner)
{
MainMenu=CreateMenu();
FileMenu=CreateMenu();
InsertMenu(MainMenu,0,MF_POPUP,(UINT)FileMenu,&quo t;&File");
AppendMenu(FileMenu,MF_STRING,ID_MENU2,"& Open");
AppendMenu(FileMenu,MF_STRING,ID_MENU3,"& Exit");
// activate the menu
if (!SetMenu(hwndOwner,MainMenu))
{
return FALSE;
}
return TRUE;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
FILE * pFile;

#define ARRAYSIZE 100
#define SONGNAME 25
#define SONGARTIST 25
#define SONGLENGTH 25
#define TRACK_NUMBER

void func1(void);
void func2(void);
void func3(void);
void func4(void);
void delete_song(void);
void func6(void);

typedef struct Mp3rec
{
        char name[SONGNAME];
        char artist[SONGARTIST];
        char length[SONGLENGTH];
        char tname[TRACK_NUMBER];
};


int main (void)
{



    int menuchoice=0;
    //fp= fopen("mp3_list.txt", "r" "W" "a"); either to add or read a text file.
    do
    {
      printf ("********************************************\n");
      printf ("************************************\n");
      printf ("*********** MP3 Player **********\n");
      printf ("********************************************");
      printf("\n1: Play File");
      printf("\n2: Show Library");
      printf("\n3: Add Record");
      printf("\n4: Edit/Modify ");
      printf("\n5: Delete Record");
      printf("\n6: Quit");

      printf("\n\nEnter Choice From 1-6: ");
      scanf("&#37;d", &menuchoice);

      switch (menuchoice)
      {
             case 1:
                    func1();
                    break;
             case 2:
                    func2();
                    break;
             case 3:
                    func3();
                    break;
             case 4:
                    func4();
                    break;

             case 5:delete_song();
                    break;

             case 6:
                    break;

             default:
                     printf("\nInvalid Choice: 1-4 Only Please");
                     }

                     }while(menuchoice!=4);
                     system("pause");
}

void func1(void)
{
     printf("\n\n Play File\n\n");
     printf ("********************************************\n");
     printf ("************************************\n");
     printf ("*********** **********\n");
     printf ("********************************************");
     {
    char commandarray[ARRAYSIZE];

    char mp3filename[ARRAYSIZE] ="C:\\mplayer\\Robin S - Show me Love.mp3";

    sprintf(commandarray"C:\\mplayer\\mplayer.exe \"%s\""mp3filename);

    printf("\nAttempting to Run Command \"%s\"...\n\n"commandarray);

    system(commandarray);

    int menuchoice=0;
    switch (menuchoice)
    printf("\n1: Back To Menu");
    printf("\n5: Quit");

    printf("\nDone.\n\n");




    system("pause");

}
}

void func2(void)
{
     printf("\n\n Show Library\n\n");
}

void func3(void)
{

     printf("\n\n Add Record/Song\n\n");
     fopen("ListofSongs.txt","r+");

     printf("\n\n Add Record\n\n");


}

void func4(void)
{
     printf("\n\n Edit/Modify the Current Song\n\n");
}

void delete_song(void)
{
     printf("\n\n Delete File\n\n");

 int i;
 int track_number;


     printf("Please Enter the track number that you wish to delete:");
     fflush(stdin);
     scanf("%d", &track_number);

}

     //for( Track_Number = Track_Number ; Track_Number <=Total Songs ; Track_Number ++)


void func6(void)
{
    // break;
}


#include<stdio.h>
void main()
{
int n; // n is a general numberi.e integer number.
printf("Enter any integers numbers:");
scanf("%d",&n);
if(n>0)
{printf("answer is a positive number");
}
else
{
if(n==0)
{printf("answer is a zero");}
else
{printf("answer is negative");}
}
}


/*write a program to count the amount entered
in note format*/
#include<stdio.h>
void main()
{
int amount;// amount entered by user
int note500,note100,note50,note20,note10,note5,note2;// notes
/* intiliasing note will be zero */
note500=note100=note50=note50=note20=note10=note5=note2=0;
printf("Enter the amount");
scanf("%d",&amount);
if(amount>=500)
{note500=amount/500;
amount=amount-(note500*500);
}
if(amount>=100)
{note100=amount/100;
amount=amount-(note100*100);
}
if(amount>=50)
{
note50=amount/50;
amount=amount-(note50*50);
}
if(amount>=20)
{
note20=amount/20;
amount=amount-(note20*20);
}
if(amount>=10)
{
note10=amount/10;
amount=amount-(note10*10);
}
if(amount>=5)
{
note5=amount/5;
amount=amount-(note5*5);
}
if(amount>=2)
{
note2=amount;
}

/*notes print*/

printf("Totol no. of notes\n");
printf("note500:%d\n",note500);
printf("note100:%d\n",note100);
printf("note50:%d\n",note50);
printf("note20:%d\n",note20);
printf("note10:%d\n",note10);
printf("note5:%d\n",note5);
printf("note2:%d\n",note2);




}



//write a program to find square roots of a any number
#include<stdio.h>
#include<math.h>
void main()
{
int a,squaroot;
printf("Enter the number to find square roots:\n");
scanf("%d",&a);
squaroot=sqrt(a);
printf("Square root of number is %d",squaroot);




}


//write a program to print star swatik


#include<stdio.h>
int main()
{
int i,j,N; // i,j are rows and column
printf("Input column or rows:\n");
scanf("%d",&N);
for(i=1;i<=N;i++)

{
for(j=1;j<=N;j++)
{
if(i==1||i==N||j==1||j==N||j==N/2||i==N/2)
printf("*");
else
{
printf(" ");}


}
printf("\n");
}




}


#include<stdio.h>
int main()
{
int i,j,rows;
printf("Input the no. of rows:\n");
scanf("%d",&rows);
for(i=1;i<=rows;i++)
{
for(j=1;j<=rows;j++)
{printf("*");
}
printf("\n");

}
return 0;
}




No comments:

Python if / else

 Python if / else a1 = int ( input (" Enter the number: \n ")) a2 = int ( input (" Enter the number: \n ")) a3 = int ( i...