answersLogoWhite

0

Write your own printf and scanf functions?

Updated: 10/25/2022
User Avatar

Vprabakaran2324

Lvl 1
14y ago

Best Answer

just include #define next to #include

or
/*just follow the pattern below*/ example:






#include
#include
#define pf printf
#define sf scanf
void main
{
int number

pf("Enter a value:");
sf("%i",&number);

getch();
}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write your own printf and scanf functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What types of database exist in c plus plus?

#include <stdio.h> main() { FILE *a; int sno,tm,em,mm,scm,sm,hm; char sname[20],any[1]; clrscr(); a=fopen("student.dat","a"); do { printf("Enter Student Number : "); scanf("%d",&sno); printf("Enter Student Name : "); scanf("%s",sname); printf("Enter Telugu Marks : "); scanf("%d",&tm); printf("Enter English Marks : "); scanf("%d",&em); printf("Enter Maths Marks : "); scanf("%d",&mm); printf("Enter Science Marks : "); scanf("%d",&scm); printf("Enter Social Marks : "); scanf("%d",&sm); printf("Enter Hindi Marks : "); scanf("%d",&hm); fprintf(a,"%d %s %d %d %d %d %d %d\n",sno,sname,tm,em,mm,scm,sm,hm); printf("Do you wish to continue(Y/N)"); scanf("%s",any); }while(strcmp(any,"y")==0); fclose(a); }


C program to create symbol table?

Aim:To write a C program to implement Symbol Table system software lab CS1207Algorithm:Start the program for performing insert, display, delete, search and modify option in symbol tableDefine the structure of the Symbol TableEnter the choice for performing the operations in the symbol TableIf the entered choice is 1, search the symbol table for the symbol to be inserted. If the symbol is already present, it displays "Duplicate Symbol". Else, insert the symbol and the corresponding address in the symbol table.If the entered choice is 2, the symbols present in the symbol table are displayed.If the entered choice is 3, the symbol to be deleted is searched in the symbol table. If it is not found in the symbol table it displays "Label Not found". Else, the symbol is deleted.If the entered choice is 5, the symbol to be modified is searched in the symbol table. The label or address or both can be modified.Source Code program in c implement symbol table# include # include # include # include # define null 0int size=0;void insert();void del();int search(char lab[]);void modify();void display();struct symbtab{char label[10];int addr;struct symtab *next;};struct symbtab *first,*last;void main(){int op;int y;char la[10];clrscr();do{printf("\nSYMBOL TABLE IMPLEMENTATION\n");printf("1. INSERT\n");printf("2. DISPLAY\n");printf("3. DELETE\n");printf("4. SEARCH\n");printf("5. MODIFY\n");printf("6. END\n");printf("Enter your option : ");scanf("%d",&op);switch(op){case 1:insert();display();break;case 2:display();break;case 3:del();display();break;case 4:printf("Enter the label to be searched : ");scanf("%s",la);y=search(la);if(y==1){printf("The label is already in the symbol Table");}else{printf("The label is not found in the symbol table");}break;case 5:modify();display();break;case 6:break;}}while(oplabel,l);printf("Enter the address : ");scanf("%d",&p->addr);p->next=null;if(size==0){first=p;last=p;}else{last->next=p;last=p;}size++;}}void display(){int i;struct symbtab *p;p=first;printf("LABEL\tADDRESS\n");for(i=0;ilabel,p->addr);p=p->next;}}int search(char lab[]){int i,flag=0;struct symbtab *p;p=first;for(i=0;ilabel,lab)==0){flag=1;}p=p->next;}return flag;}void modify(){char l[10],nl[10];int add, choice, i, s;struct symbtab *p;p=first;printf("What do you want to modify?\n");printf("1. Only the label\n");printf("2. Only the address of a particular label\n");printf("3. Both the label and address\n");printf("Enter your choice : ");scanf("%d",&choice);switch(choice){case 1:printf("Enter the old label\n");scanf("%s",l);printf("Enter the new label\n");scanf("%s",nl);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){strcpy(p->label,nl);}p=p->next;}}break;case 2:printf("Enter the label whose address is to modified\n");scanf("%s",l);printf("Enter the new address\n");scanf("%d",&add);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){p->addr=add;}p=p->next;}}break;case 3:printf("Enter the old label : ");scanf("%s",l);printf("Enter the new label : ");scanf("%s",nl);printf("Enter the new address : ");scanf("%d",&add);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){strcpy(p->label,nl);p->addr=add;}p=p->next;}}break;}}void del(){int a;char l[10];struct symbtab *p,*q;p=first;printf("Enter the label to be deleted\n");scanf("%s",l);a=search(l);if(a==0){printf("Label not found\n");}else{if(strcmp(first->label,l)==0){first=first->next;}else if(strcmp(last->label,l)==0){q=p->next;while(strcmp(q->label,l)!=0){p=p->next;q=q->next;}p->next=null;last=p;}else{q=p->next;while(strcmp(q->label,l)!=0){p=p->next;q=q->next;}p->next=q->next;}size--;}}


Write a function that print a triangle of stars?

Function to print star triangle in c++#include#includevoid starfunction(int); //You can give any function namevoid main(){int a;clrscr();couta;star(a);getch();}void starfunction(int r ){for(int i=1;i


C program to multiply two numbers without using arithmetic operator and using recursive function?

# include<stdio.h> main() { int a,b,i: int result=0; printf("enter two numbers to be multipied"); scanf("%d%d",&A,&B); for(i=1;i<=b;i++) result=result+A; printf("%d*%d=%d\n",a,b,result); }


How do you implement stack using singly linked list?

struct node { int info; struct node *link; } *top=NULL; int main() { int choice; while(1) { printf("1.Push\n"); printf("2.Pop\n"); printf("3.Display\n"); printf("4.Quit\n"); printf("Enter your choice : ") ; scanf("%d", &choice); switch(choice) { case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: exit(1); default : printf("Wrong choice\n"); }/*End of switch */ }/*End of while */ return 0; }/*End of main() */ void push() { struct node *tmp; int pushed_item; tmp = malloc(sizeof(struct node)); printf("Input the new value to be pushed on the stack : "); scanf("%d",&pushed_item); tmp->info=pushed_item; tmp->link=top; top=tmp; }/*End of push()*/ void pop() { struct node *tmp; if(top == NULL) printf("Stack is empty\n"); else { tmp=top; printf("Popped item is %d\n",tmp->info); top=top->link; free(tmp); } }/*End of pop()*/ void display() { struct node *ptr; ptr=top; if(top==NULL) printf("Stack is empty\n"); else { printf("Stack elements :\n"); while(ptr!= NULL) { printf("%d\n",ptr->info); ptr = ptr->link; }/*End of while */ }/*End of else*/ }/*End of display()*/

Related questions

What types of database exist in c plus plus?

#include <stdio.h> main() { FILE *a; int sno,tm,em,mm,scm,sm,hm; char sname[20],any[1]; clrscr(); a=fopen("student.dat","a"); do { printf("Enter Student Number : "); scanf("%d",&sno); printf("Enter Student Name : "); scanf("%s",sname); printf("Enter Telugu Marks : "); scanf("%d",&tm); printf("Enter English Marks : "); scanf("%d",&em); printf("Enter Maths Marks : "); scanf("%d",&mm); printf("Enter Science Marks : "); scanf("%d",&scm); printf("Enter Social Marks : "); scanf("%d",&sm); printf("Enter Hindi Marks : "); scanf("%d",&hm); fprintf(a,"%d %s %d %d %d %d %d %d\n",sno,sname,tm,em,mm,scm,sm,hm); printf("Do you wish to continue(Y/N)"); scanf("%s",any); }while(strcmp(any,"y")==0); fclose(a); }


Source code of love meter in c-programming?

/* LOVE METER */#include#includevoid predict(void);void main(){char n;clrscr();predict();printf("\n\nAre you want to check again with another partner\n");scanf("%s",&n);if(n=='y'){predict();}printf("\n\n\n****Thank You****\n\n\n");printf("\t\t\t\t\t@sawan soft.");getch();}void predict(void){char a[25],b[25];int m,n,l,i,j;printf("****Welcome to prediction game ****\n");printf("\n******Enter your name******\n");scanf("%s",a);for(i=0;a[i]!='\0';i++){b[i] =a[i];}printf("\n\n******Enter your partner name******\n");scanf("%s",b);for(j=0;b[j]!='\0';j++){a[j]=b[j];}l=i+j;if(l==1l==7l==13l==19){printf("\n****FREIND****\n");printf("\nyou will be freind not so more....");}if(l==2l==8l==14l==20){printf("\n****LOVE****\n");printf("\nYou can sucess own love....");}if(l==3l==9l==15l==21){printf("\n****AFFECTION****\n");printf("\nyou are in attraction, tell your heart felling soon....");}if(l==4l==10l==16l==22){printf("\n****MARRIAGE****\n");printf("\nYou got sucess in love....");}if(l==5l==11l==17l==23){printf("\n****ENEMY****\n");printf("\nKeep distance from them....");}


C program to create symbol table?

Aim:To write a C program to implement Symbol Table system software lab CS1207Algorithm:Start the program for performing insert, display, delete, search and modify option in symbol tableDefine the structure of the Symbol TableEnter the choice for performing the operations in the symbol TableIf the entered choice is 1, search the symbol table for the symbol to be inserted. If the symbol is already present, it displays "Duplicate Symbol". Else, insert the symbol and the corresponding address in the symbol table.If the entered choice is 2, the symbols present in the symbol table are displayed.If the entered choice is 3, the symbol to be deleted is searched in the symbol table. If it is not found in the symbol table it displays "Label Not found". Else, the symbol is deleted.If the entered choice is 5, the symbol to be modified is searched in the symbol table. The label or address or both can be modified.Source Code program in c implement symbol table# include # include # include # include # define null 0int size=0;void insert();void del();int search(char lab[]);void modify();void display();struct symbtab{char label[10];int addr;struct symtab *next;};struct symbtab *first,*last;void main(){int op;int y;char la[10];clrscr();do{printf("\nSYMBOL TABLE IMPLEMENTATION\n");printf("1. INSERT\n");printf("2. DISPLAY\n");printf("3. DELETE\n");printf("4. SEARCH\n");printf("5. MODIFY\n");printf("6. END\n");printf("Enter your option : ");scanf("%d",&op);switch(op){case 1:insert();display();break;case 2:display();break;case 3:del();display();break;case 4:printf("Enter the label to be searched : ");scanf("%s",la);y=search(la);if(y==1){printf("The label is already in the symbol Table");}else{printf("The label is not found in the symbol table");}break;case 5:modify();display();break;case 6:break;}}while(oplabel,l);printf("Enter the address : ");scanf("%d",&p->addr);p->next=null;if(size==0){first=p;last=p;}else{last->next=p;last=p;}size++;}}void display(){int i;struct symbtab *p;p=first;printf("LABEL\tADDRESS\n");for(i=0;ilabel,p->addr);p=p->next;}}int search(char lab[]){int i,flag=0;struct symbtab *p;p=first;for(i=0;ilabel,lab)==0){flag=1;}p=p->next;}return flag;}void modify(){char l[10],nl[10];int add, choice, i, s;struct symbtab *p;p=first;printf("What do you want to modify?\n");printf("1. Only the label\n");printf("2. Only the address of a particular label\n");printf("3. Both the label and address\n");printf("Enter your choice : ");scanf("%d",&choice);switch(choice){case 1:printf("Enter the old label\n");scanf("%s",l);printf("Enter the new label\n");scanf("%s",nl);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){strcpy(p->label,nl);}p=p->next;}}break;case 2:printf("Enter the label whose address is to modified\n");scanf("%s",l);printf("Enter the new address\n");scanf("%d",&add);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){p->addr=add;}p=p->next;}}break;case 3:printf("Enter the old label : ");scanf("%s",l);printf("Enter the new label : ");scanf("%s",nl);printf("Enter the new address : ");scanf("%d",&add);s=search(l);if(s==0){printf("NO such label");}else{for(i=0;ilabel,l)==0){strcpy(p->label,nl);p->addr=add;}p=p->next;}}break;}}void del(){int a;char l[10];struct symbtab *p,*q;p=first;printf("Enter the label to be deleted\n");scanf("%s",l);a=search(l);if(a==0){printf("Label not found\n");}else{if(strcmp(first->label,l)==0){first=first->next;}else if(strcmp(last->label,l)==0){q=p->next;while(strcmp(q->label,l)!=0){p=p->next;q=q->next;}p->next=null;last=p;}else{q=p->next;while(strcmp(q->label,l)!=0){p=p->next;q=q->next;}p->next=q->next;}size--;}}


Write a function that print a triangle of stars?

Function to print star triangle in c++#include#includevoid starfunction(int); //You can give any function namevoid main(){int a;clrscr();couta;star(a);getch();}void starfunction(int r ){for(int i=1;i


C program to multiply two numbers without using arithmetic operator and using recursive function?

# include<stdio.h> main() { int a,b,i: int result=0; printf("enter two numbers to be multipied"); scanf("%d%d",&A,&B); for(i=1;i<=b;i++) result=result+A; printf("%d*%d=%d\n",a,b,result); }


Where can you write your own lyrics?

I write them in my diary.


What is the ISBN of In His Own Write?

The ISBN of In His Own Write is 0684868075.


Who wrote in his own write?

John Lennon wrote In His Own Write.


How many pages does In His Own Write have?

In His Own Write has 80 pages.


How do you write a c program to compute 2 to the power of x?

First of all you need to find the right function. And the right function for this job is power() which is located in math.h. Now you need to ask user to enter "x" value and you can compute power(2, x).Here is a small example of such application:#include #include int main() {int power = 0;printf("Enter the power: ");scanf("%d", &power);printf("2^power: %llu\n", (long long)pow(2, power));return 0;}It is still limited, only capable of giving results with x up to ~60. Because of long long type, which is the biggest of all. To get even bigger number you would need to write your own data structures for numbers and write power() function for them.Testing:Enter the power: 322^power: 4294967296Note:This code is only for example, it does not meat ANSI C90 criteria. (long long type is not supported by ASNI C90). Other than that it is working.


What is meant by functions on python?

Python programming allows you to write your own programs. For example, to write a function named double that returns the number that you input, but doubled, we would write the following (where >>>> indicates a tab space) def double(x): >>>>x=x*2 >>>>return x


Does escape the fate write their own music?

Yes, they write their own material.