View Code of Problem 79

#include <stdio.h>
change(int a[],int m){
  int i,j;
  for(i=n-1;i>=0;i--){
    a[i+m] = a[i];
  
  }
  for(i=n,j=0;i<=n+m-1;i++){
    a[j++]=a[i];
  
  }
  for(i=0;i<n;i++)
  printf("%d",a[i]);
  

}
int main(){
  int n,m;
  int a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  scanf("%d",&m);
  change(a,m)
  
    return 0;
}
  
/*
Main.c:2:1: warning: return type defaults to 'int'
 change(int a[],int m){
 ^
Main.c: In function 'change':
Main.c:4:9: error: 'n' undeclared (first use in this function)
   for(i=n-1;i>=0;i--){
         ^
Main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in
Main.c:8:10: warning: left-hand operand of comma expression has no effect [-Wunused-value]
   for(i=n,j=0;i<=n+m-1;i++){
          ^
Main.c: In function 'main':
Main.c:21:7: error: 'i' undeclared (first use in this function)
   for(i=0;i<n;i++)
       ^
Main.c:26:5: error: expected ';' before 'return'
     return 0;
     ^
Main.c: In function 'change':
Main.c:16:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
*/

Double click to view unformatted code.


Back to problem 79